package org.yzhzc.job.mapper.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.yzhzc.job.domain.user.dto.UserScoreDTO;
import org.yzhzc.job.domain.user.entity.UserExam;


import java.util.List;


public interface UserExamMapper extends BaseMapper<UserExam> {

    /**
     * 批量更新用户成绩和排名
     *
     * @param userScoreList 用户成绩和排名列表
     */
    @Update("<script>" +
            "<foreach collection='userScoreList' item='item' separator=';'>" +
            "UPDATE tb_user_exam " +
            "SET score = #{item.score}, exam_rank = #{item.examRank} " +
            "WHERE exam_id = #{item.examId} AND user_id = #{item.userId} " +
            "</foreach>" +
            "</script>")
    void updateUserScoreAndRank(@Param("userScoreList") List<UserScoreDTO> userScoreList);
}
